package com.cskaoyan.bean.goods.base;

import com.cskaoyan.bean.goods.Goods;
import com.github.pagehelper.PageInfo;
import lombok.Data;

import java.util.Collections;
import java.util.List;

/**
 * @Description:
 * @author: Jason 805636901@qq.com
 * @create: 2021-10-18-11:38 PM
 */
@Data
public class GoodsPageData<T> {
    Integer limit;
    Integer page;
    Integer pages;
    Integer total;
    List<T> list;

    public static<T> GoodsPageData ok(List<T> goods ) {
        PageInfo<T> goodsPageInfo = new PageInfo<T>(goods);

        GoodsPageData<T> data = new GoodsPageData<>();
        data.setPage(goodsPageInfo.getPageNum());
        data.setLimit(goodsPageInfo.getPageSize());
        data.setPages(goodsPageInfo.getPages());
        data.setTotal((int) goodsPageInfo.getTotal());
        data.setList(goods);

        return data;

    }


}
